Loading...
 

CX_CONDITIONED_BAG - Conditional object tables

CX_CONDITIONED_BAG

Class hierarchy
Description:

This class manages "If...then" relationships in a table. A table entry consists of a condition ("If") and an object assigned to it ("Then"). An entry is managed with a formula condition.

When the table is evaluated, the object whose assigned condition is fulfilled is delivered. I.e. in this case the table behaves like a kind of switch .

Example:

If... Then...
Order quantity < 50 & customer = "Meier" Discount = 6%
Orderquantity < 50Discount = 5%
Orderquantity < 100Unit price = DM 49.89
Order quantity >= 100 Discount = 8%

In the example, a price table containing special customer discounts is shown. Here, the customer "Meier" receives a special discount of "6%" for order quantities of less than 50 units. If, on the other hand, the customer "Müller" orders a quantity of 25 units, "5%" is returned as a discount.

It should also be noted that the individual entries can also deliver different objects. For example, if the order quantity is between 50 and 100, a unit price of "49.89 DM" is agreed, so that the returned object is not a percentage, but a value .

Code example:

Eine bedingte Objekttabelle besteht aus einer Menge von Formel-Bedingungen. Es gibt folgende Möglichkeiten, um einen neuen Eintrag in die Tabelle zu stellen.

1. Erzeugen einer Formel-Bedingung und Einfügen dieser in die Tabelle:

  Var(fcond)CreateTransObject(CX_FCONDITION) -> fcond
  "Bestellmenge < 50 & Kunde = \"Meier\"" fcond Put
  . . .  // Erzeugen des Objektes "o", das an die Bedingung gebunden ist
  // Objekt "o" an die Bedingung binden
  o fcond SetReference(_object)
  Var(table) CreateTransObject(CX_CONDITIONED_BAG) -> table
  // Einfügen in die Tabelle
  fcond table Insert
      

2. Direkte Übergabe der Bedingung als Text und des zugehörigen Objektes "o" an die Tabelle, die keine Spaltenaufteilung besitzt.

  Var(table) CreateTransObject(CX_CONDITIONED_BAG) -> table
  . . .  // Erzeugen des Objektes "o", das an die Bedingung gebunden ist
  // Einfügen in die Tabelle
  "Bestellmenge < 50 & Kunde = \"Meier\"" o table Insert
      

3. Direkte Übergabe der Bedingung als Text und des zugehörigen Objektes "o" an die Tabelle, wobei eine Spaltenaufteilung für die Tabelle definiert ist und die Bedingung dementsprechend aufgeteilt ist. Die einzelnen Bestandteile müssen dabei mit einem "Und" (= "&") verknüpft sein.

  Var(table) CreateTransObject(CX_CONDITIONED_BAG) -> table
  "Bestellmenge, Kunde" table Put
  . . .  // Erzeugen des Objektes "o", das an die Bedingung gebunden ist
  // Format: expr (=Rest) Kunde Bestellmenge Objekt
  "" "Meier" "<50" o table Insert
  // Alternativ kann statt "Meier" auch "=Meier" geschrieben werden      

Note: Instead of an entry, a vector of entries can be passed to the table for insertion.

Display on screen

An object box provides the functionality to display the individual entries of a conditional object table. An example display is shown in the following graphic (programme code and further notes):

In this example, the column division options have been used to make the display clearer.

Method directory (MDI)
FunctionMA*ParameterReturnShort description
AddColVar STRING. Add a new column to the defined ones
Amount OBJECTReturn the value of the first object whose condition is met.
ColVarNames VECTOR&lmt;STRING>Returning the column names
ColVarNumbers VECTOR&lmt;INTEGER>Returning the column numbers
ColVarTypes VECTOR&lmt;INTEGER>Return of the column types
Delete OBJECT. Delete formula condition from the table
Evaluate OBJECTReturn the first object whose condition is met.
Exchange
FindAll COLLReturn all formula-condition objects
First OBJECT
GetInputAccessPaths
233188
VECTOR&lmt;STRING>Return all access ports in a vector.
GetInputVarNames OBJECT.VECTOR&lmt;STRING>Return all variable names in a vector.
InsertAfter OBJECT, OBJECT
InsertBefore
InsertFirst OBJECT
InsertLast OBJECT
Last OBJECT
NColumnVars INTEGERDetermine number of columns
Pick OBJECTReturn the first object whose condition is met.
Pick via access expression Return the first object whose condition is fulfilled.
Query COLLReturn all objects whose condition is fulfilled
RemoveColVar STRING. Remove a column from the defined ones
Repair removes objects that are NOT formula condition objects (CX_FCONDITION) from the table.
Revert Reverses the order of the elements (CX_FCONDITIONE objects).
SanityCheck INTEGERCheck consistency of the table
Add CX_AMOUNTCX_AMOUNTOperator + as function
AddAssign CX_AMOUNT operator += as function
AmountWeak
Autoformat INTEGER, INTEGERCX_AMOUNTReturns an object formatted according to the given number of digits before and after the decimal point (only for CX_VALUE, otherwise the object itself).
DivAssign CX_AMOUNT Operator /= as a function
Divide CX_AMOUNTCX_AMOUNTOperator / as function
MulAssign CX_AMOUNT operator *= as function
Multiply CX_AMOUNTCX_AMOUNTOperator * as a function
string INTEGERCX_STRINGReturns the string representation of the object.
SubAssign CX_AMOUNT Operator -= as function
Subtract CX_AMOUNTCX_AMOUNTOperator - as a function

* MA = member access function

Data Directory (DDI)
Data fieldTypeReference classI*Brief description
thisCX_CONDITIONED_BAG The conditional object table
flagsSHORT / INTEGER (?) Controlling the evaluation via flags

I = Indexable data field

Use in AppsWH
ModuleBrief description
testform.modTest formula
columvar.modTable column editing module
cxConditionedBag.modTables base module
PriceDiscountTable.modPrice tables base module